package com.tmt.paymentcenter.web.domain;


import com.tmt.annotation.Select2OptionAttr;
import com.tmt.annotation.Select2OptionItem;
import com.tmt.annotation.SyncLoadFile;
import com.tmt.jpafieldvalueconvert.JpaFieldValueConvert;
import com.tmt.jpafieldvalueconvert.JpaFieldValueConvertListener;
import com.tmt.jpafieldvalueconvert.impl.FileUrlFieldConverter;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.OneToOne;
import java.io.Serializable;

/**
 * 开户公司
 */
@Getter
@Setter
@Entity
@EntityListeners({JpaFieldValueConvertListener.class, AuditingEntityListener.class})
public class TradeCompany extends BaseCreator implements Serializable {

    @Select2OptionItem
    @Column(nullable =  false, unique = true)
    private String name;

    @Select2OptionItem(order = 1)
    @Column(nullable = false, unique = true)
    private String code;

    @JpaFieldValueConvert(converter = FileUrlFieldConverter.class, displayName = "商户LOGO")
    @SyncLoadFile
    @Select2OptionAttr("logo")
    private String logo;


    @Column(nullable = false)
    private String address;

    /**
     * 交易结果通知Url
     */
    @Column(nullable = false, unique = true)
    private String tradeResultNotifyUrl;

    /**
     * 绑定的用户
     */
    @OneToOne(mappedBy = "bindingCompany")
    private TradeUser bindingUser;

}
